package com.logic.modular.game.battle.panel.skillEffect.domain;

import com.logic.modular.game.battle.process.domain.Reason;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SkillEffectLayer  {
    @ApiModelProperty("触发目标")
    private Long targetPlayerHeroId;
    @ApiModelProperty("触发原因")
    public Reason targetReason;
    @ApiModelProperty("字段名")
    private String name;
    @ApiModelProperty("字段中文名")
    private String info;
    @ApiModelProperty("触发次数")
    private Integer triggerCount;

    @ApiModelProperty("叠加记录")
    private Map<Integer, LayerValue> layerValueMap = new HashMap<>();

    @ApiModelProperty("最新变动数值")
    private Double thisChangeValue;
    @ApiModelProperty("最新结束值")
    private Object lastEndValue;
    @ApiModelProperty("累计变动值")
    private Double totalChangeValue;


    public void obtainThisChangeValue() {
        thisChangeValue = layerValueMap.values().stream().mapToDouble(LayerValue::getThisChangeValue).sum();
        totalChangeValue += layerValueMap.values().stream().mapToDouble(LayerValue::getThisChangeValue).sum();
    }

    public void log() {
        if (name != null && !name.equals("null")) {
            List<String> layInfo = layerValueMap.values().stream().map(LayerValue::obtainThisChangeInfo).collect(Collectors.toList());
            log.info("变动数值:{}(层数信息:{}))", thisChangeValue, layInfo);
        }
    }
}
